package com.example;

public class Demo03 {

    public static void main(String[] args) {
        /*
         1.jiecheng(3)
         2.return jiecheng(2) * 3
         3.return jiecheng(1) * 2
         jiecheng(1) * 2 * 3
         1 * 2 * 3 = 6
         */
        System.out.println(jiecheng(3));
    }

    /* 递归计算1 * 2 * ... * n的结果 */
    public static int jiecheng(int n) {
        if (n <= 0) {
            return 0;
        } else if(n == 1) {
            return 1;
        } else {
            return jiecheng(n - 1) * n;
        }
    }
}
